package com.rraj.common.exception;

import com.rraj.common.enums.ResCodeEnums;

/**
 * Created by WangSheng on 2017/7/24.
 *
 * @author WangSheng
 * @date 2017/07/24
 */
public class BaseRuntimeException extends RuntimeException{
    /**
     * 序列化ID
     */
    private static final long serialVersionUID = 1L;
    /**
     * 错误信息
     */
    private String msg;
    /**
     * 错误码
     */
    private int code;

    public String getMsg() {
        return msg;
    }

    public int getCode() {
        return code;
    }

    protected ResCodeEnums resCodeEnums;
    public ResCodeEnums getResCodeEnums() {
        return resCodeEnums;
    }

    public BaseRuntimeException(){
        super();
        this.resCodeEnums = ResCodeEnums.SYSTEM_ERROR;
    }
    public BaseRuntimeException(String msg){
        super(msg);
        this.msg = msg;
        this.code = -1;
    }
    public BaseRuntimeException(String msg, Throwable throwable){
        super(msg, throwable);
        this.msg = msg;
        this.code = -1;
    }
    public BaseRuntimeException(ResCodeEnums resCodeEnums){
        super(resCodeEnums.getResMsg());
        this.resCodeEnums = resCodeEnums;
        this.msg = resCodeEnums.getResMsg();
        this.code = resCodeEnums.getResCode();
    }
    public BaseRuntimeException(ResCodeEnums resCodeEnums, Throwable throwable){
        super(resCodeEnums.getResMsg(),throwable);
        this.resCodeEnums = resCodeEnums;
        this.msg = resCodeEnums.getResMsg();
        this.code = resCodeEnums.getResCode();
    }
}
